package com.java.tutorials.jdk7.files;
import com.java.tutorials.Constants;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
 * Created by xuzhike on 2016/1/26.
 * http://www.java2s.com/Code/Java/JDK-7/CreateBufferedReaderwithdefaultcharset.htm
 *
 * Create BufferedReader with default charset
 */
public class CreateBufferedReaderwithdefaultcharset {
    public static void main(String[] args) {
        Path path = null;
        try {
            path = Paths.get(new URI("file:///"+ Constants.TEST_FILE_WITH_PATH));
        } catch (URISyntaxException e) {
            System.out.println("Bad URI");
        }

        try (BufferedReader inputReader = Files.newBufferedReader(path, Charset.defaultCharset())) {
            String inputLine;
            while ((inputLine = inputReader.readLine()) != null) {
                System.out.println(inputLine);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

    }
}
